// @flow
import React, { Component, Fragment } from 'react';
import { connect } from 'react-redux';
import type { State } from 'store';
import TreeNode from 'components/Common/TreeNode';
import ClassifyItem from 'components/Thing/ClassifyItem';
import storage, { keys } from 'lib/storage';
import Qs from 'qs';

type Props = {
    data: any,
    openedIds: Array<string>,
    contenteditable: boolean,
    index: number,
    openingIds: Array<string>,
    isEmailSended: boolean
};

class ClassifyContainer extends Component<Props> {
    constructor(props: Props) {
        super(props);
        this.renderItems = this.renderItems.bind(this);
    }
    spanChange = id => {
        console.log(id);
    };
    spanDbClickHandle = id => {
        console.log(id);
    };

    render() {
        const { data, openedIds } = this.props;
        return (
            <Fragment>
                <TreeNode
                    datas={data}
                    openedIds={openedIds}
                    treeType={'classify'}
                    NodeRender={(item, isLeaf, isOpen, nodeType,EditableIds) => {
                        return <ClassifyItem data={item}
                        isLeaf={isLeaf}
                        isOpen={isOpen}
                        nodeType={      }
                        EditableIds={EditableIds}
                        nodeItemType: string,
                        editableInputRef: Element,
                        onClassifyEditorOutSideClick(id: string): void,
                        onEditablItemChange(id: string): void,
                        onEditableItemDoubleClick(id: string): void,
                        onNodeClick(id: string): void/>;
                    }}
                />
            </Fragment>
        );
    }
}
// 把store导入Pros
const mapStatetoProps = ({ base, auth, things }: State) => {
    return {
        user: auth.user,
        data: things.classify ? things.classify : null
    };
};

const mapDispatchtoProps = () => ({});
export default connect(
    mapStatetoProps,
    mapDispatchtoProps
)(ClassifyContainer);
